<!DOCTYPE html>
<html>
<!-- 增加云服务窗口 -->
<form action="#" method="post" id="selectWidget">
	<table class="table table-bordered">
		<thead>
			<tr>
				<th><input class="choice" type="checkbox" name="checkbox"
					id="selectAll" value="" onclick="checkAll(this)"></th>
				<th>名称</th>
				<th>描述</th>
			</tr>
		</thead>
		<tbody id="selecttableCloud">
			{{^resultList}}
			<tr>
				<td colspan="3" class="text-center">暂时没有可添加的云服务 <input
					type="hidden" id="textcenter" name="textcenter" value="textcenter" />
				</td>
			</tr>
			{{/resultList}} {{#resultList}}
			<tr>
				<td><input class="choice-w" type="checkbox" name="widget_id"
					id="{{id}}" value="{{id}}"></td>
				<td>{{name}}</td>
				<td>{{discription}}</td>
			</tr>
			{{/resultList}}
		</tbody>
	</table>
</form>
</html>

<script type="text/javascript">
	/* 获取多选框项id */
	function checkAll(obj) {
		if (obj.checked) {
			$("#selecttableCloud input[class='choice-w']").each(
					function(index) {
						this.checked = true;
					});
		} else {
			$("#selecttableCloud input[class='choice-w']").each(
					function(index) {
						this.checked = false;

					});
		}
	}

	/* 获取多选框项id */
	function getIds() {
		var checkIdentifys = [];
		$("#selecttableCloud input[class='choice-w']").each(function(index) {
			if ($(this).is(':checked')) {
				var id = $(this).val();
				checkIdentifys.push(id);
			}
		});
		return checkIdentifys;
	}

	function saveCloud(appId) {

		var textcenter = $("#textcenter").val() //没有可关联的云服务
		if (textcenter == "textcenter") {
			return;
		}
		var ids = getIds();
		var data = [ {
			name : 'Ids',
			value : ids
		}, {
			name : 'appId',
			value : appId

		} ];
		$.ajax({
			url : "{{ctx}}/mam/appMain/cloud/add",
			type : 'post',
			data : data,
			success : function(resultData) {
				$('#myModal').modal("hide");
				bootbox.alert("添加成功", function() {
					window.location.reload();
				});
			},
			error : function() {
				bootbox.alert("系统繁忙，请稍后再试！");
			}
		});
	}
</script>